<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"movie0125.gitee.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="LFS学习笔记（二）编译Binutils和GCC。本章节所有指令在 lfs 用户下执行, 执行命令 su - lfs 切换到 lfs 用户。">
<meta property="og:type" content="article">
<meta property="og:title" content="lfs-notebook-02">
<meta property="og:url" content="https://movie0125.gitee.io/2021/05/11/lfs-notebook-02/index.html">
<meta property="og:site_name" content="Movie Blog">
<meta property="og:description" content="LFS学习笔记（二）编译Binutils和GCC。本章节所有指令在 lfs 用户下执行, 执行命令 su - lfs 切换到 lfs 用户。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-05-11T08:53:24.000Z">
<meta property="article:modified_time" content="2021-05-13T00:39:06.970Z">
<meta property="article:author" content="Movie">
<meta property="article:tag" content="LFS">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://movie0125.gitee.io/2021/05/11/lfs-notebook-02/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>lfs-notebook-02 | Movie Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Movie Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">拥抱开源，快乐分享</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://movie0125.gitee.io/2021/05/11/lfs-notebook-02/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Movie">
      <meta itemprop="description" content="学习，记录，分享，收获">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Movie Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          lfs-notebook-02
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-11 16:53:24" itemprop="dateCreated datePublished" datetime="2021-05-11T16:53:24+08:00">2021-05-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-05-13 08:39:06" itemprop="dateModified" datetime="2021-05-13T08:39:06+08:00">2021-05-13</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">学习笔记</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/11/lfs-notebook-02/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/11/lfs-notebook-02/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="LFS学习笔记（二）"><a href="#LFS学习笔记（二）" class="headerlink" title="LFS学习笔记（二）"></a>LFS学习笔记（二）</h1><p>编译Binutils和GCC。<br>本章节所有指令在 <code>lfs</code> 用户下执行, 执行命令 <code>su - lfs</code> 切换到 lfs 用户。</p>
<a id="more"></a>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">再次强调构建的过程：</span><br><span class="line"></span><br><span class="line">把所有源文件和补丁放到 chroot 环境可访问的目录，例如 &#x2F;mnt&#x2F;lfs&#x2F;sources&#x2F;。但是千万不能把源文件放在 &#x2F;mnt&#x2F;lfs&#x2F;tools&#x2F; 中。</span><br><span class="line">进入到源文件目录。</span><br><span class="line">对于每个软件包：</span><br><span class="line">用 tar 程序解压要编译的软件包。在第五章中，确保解压软件包时你使用的是 lfs 用户。</span><br><span class="line">进入到解压后创建的目录中。</span><br><span class="line">根据指南说明编译软件包。</span><br><span class="line">回退到源文件目录。</span><br><span class="line">除非特别说明，删除解压出来的目录。</span><br></pre></td></tr></table></figure>
<h2 id="编译-Binutils-2-32-第-1-遍"><a href="#编译-Binutils-2-32-第-1-遍" class="headerlink" title="编译 Binutils-2.32 - 第 1 遍"></a>编译 Binutils-2.32 - 第 1 遍</h2><p>Binutils 是首个安装的包，因为无论是执行 GCC 还是 Glibc 的 configure 时，都将围绕关汇编器和链接器实施多项特性测试，来判断哪些软件特性要启用或是禁用。其重要性可能更甚于你对它的第一印象。GCC 或 Glibc 的错误配置会导致工具链出现难以捉摸的问题，可能直到整个构建过程接近尾声时，这些问题才会显现出来。不过，通常情况下，在你进行大量的无用功之前，一次测试套件的失败便会将该错误高亮出来。</p>
<p>Binutils 将其汇编器和链接器安装在两处，/tools/bin 和 /tools/$LFS_TGT/bin。有一处的工具是另一处的硬链接。链接器的一个重要方面是它的库搜索顺序。可以给 ld 传递参数 –verbose 获取详细信息。例如，ld –verbose | grep SEARCH 将说明当前的搜索路径及其顺序。通过编译一个 dummy（假）程序并向链接器传递 –verbose 参数，可显示 ld 都链接了哪些文件。例如，gcc dummy.c -Wl,–verbose 2&gt;&amp;1 | grep succeeded 将显示链接过程中成功打开的所有文件。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">cd $LFS&#x2F;sources</span><br><span class="line">mkdir build</span><br><span class="line">cd build</span><br><span class="line"></span><br><span class="line">tar xf ..&#x2F;binutils-2.32.tar.xz</span><br><span class="line">mv binutils-2.32 binutils</span><br><span class="line">cd binutils</span><br><span class="line"></span><br><span class="line">.&#x2F;configure --prefix&#x3D;&#x2F;tools            \</span><br><span class="line">             --with-sysroot&#x3D;$LFS        \</span><br><span class="line">             --with-lib-path&#x3D;&#x2F;tools&#x2F;lib \</span><br><span class="line">             --target&#x3D;$LFS_TGT          \</span><br><span class="line">             --disable-nls              \</span><br><span class="line">             --disable-werror</span><br><span class="line"></span><br><span class="line">make -j2</span><br><span class="line"></span><br><span class="line">case $(uname -m) in</span><br><span class="line">  x86_64) mkdir -v &#x2F;tools&#x2F;lib &amp;&amp; ln -sv lib &#x2F;tools&#x2F;lib64 ;;</span><br><span class="line">esac</span><br><span class="line"></span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h2 id="安GCC-9-2-0-第-1-遍"><a href="#安GCC-9-2-0-第-1-遍" class="headerlink" title="安GCC-9.2.0 - 第 1 遍"></a>安GCC-9.2.0 - 第 1 遍</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> <span class="variable">$LFS</span>/sources/build/</span><br><span class="line"></span><br><span class="line">tar xf ../gcc-9.2.0.tar.xz </span><br><span class="line">mv gcc-9.2.0 gcc</span><br><span class="line"></span><br><span class="line"><span class="built_in">cd</span> gcc</span><br><span class="line"></span><br><span class="line"><span class="comment"># 编译 gcc时需要同时编译 mpfr  gmp  mpc</span></span><br><span class="line"><span class="comment"># 所以需要把这三个包解压到 gcc 目录中</span></span><br><span class="line">tar -xf ../../mpfr-4.0.2.tar.xz</span><br><span class="line">mv -v mpfr-4.0.2 mpfr</span><br><span class="line">tar -xf ../../gmp-6.1.2.tar.xz</span><br><span class="line">mv -v gmp-6.1.2 gmp</span><br><span class="line">tar -xf ../../mpc-1.1.0.tar.gz</span><br><span class="line">mv -v mpc-1.1.0 mpc</span><br><span class="line"></span><br><span class="line"><span class="comment"># 复制文件 gcc/config/linux.h，gcc/config/i386/linux.h，和 gcc/config/i368/linux64.h，给复制的文件加上「.orig」后缀。然后第一个 sed 表达式在每个「/lib/ld」，「/lib64/ld」或者「/lib32/ld」实例前面增加「/tools」，第二个 sed 表达式替换「/usr」的硬编码实例。然后，我们添加这改变默认 startfile 前缀到文件末尾的定义语句。注意「/tools/lib/」后面的「/」是必须的。最后，我们用 touch 更新复制文件的时间戳。当与 cp -u 一起使用时，可以防止命令被无意中运行两次造成对原始文件意外的更改</span></span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> gcc/config/&#123;linux,i386/linux&#123;,64&#125;&#125;.h</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line">  cp -uv <span class="variable">$file</span>&#123;,.orig&#125;</span><br><span class="line">  sed -e <span class="string">&#x27;s@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g&#x27;</span> \</span><br><span class="line">      -e <span class="string">&#x27;s@/usr@/tools@g&#x27;</span> <span class="variable">$file</span>.orig &gt; <span class="variable">$file</span></span><br><span class="line">  <span class="built_in">echo</span> <span class="string">&#x27;</span></span><br><span class="line"><span class="string">#undef STANDARD_STARTFILE_PREFIX_1</span></span><br><span class="line"><span class="string">#undef STANDARD_STARTFILE_PREFIX_2</span></span><br><span class="line"><span class="string">#define STANDARD_STARTFILE_PREFIX_1 &quot;/tools/lib/&quot;</span></span><br><span class="line"><span class="string">#define STANDARD_STARTFILE_PREFIX_2 &quot;&quot;&#x27;</span> &gt;&gt; <span class="variable">$file</span></span><br><span class="line">  touch <span class="variable">$file</span>.orig</span><br><span class="line"><span class="keyword">done</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#在 x86_64 的主机上，为 64 位的库设置默认目录名至「lib」：</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">case</span> $(uname -m) <span class="keyword">in</span></span><br><span class="line">  x86_64)</span><br><span class="line">    sed -e <span class="string">&#x27;/m64=/s/lib64/lib/&#x27;</span> \</span><br><span class="line">        -i.orig gcc/config/i386/t-linux64</span><br><span class="line"> ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 在gcc目录下再创建一个build目录，用来编译</span></span><br><span class="line"><span class="comment"># 保持源码目录干净</span></span><br><span class="line">mkdir build </span><br><span class="line"><span class="built_in">cd</span> build </span><br><span class="line"></span><br><span class="line">../configure                                       \</span><br><span class="line">    --target=<span class="variable">$LFS_TGT</span>                              \</span><br><span class="line">    --prefix=/tools                                \</span><br><span class="line">    --with-glibc-version=2.11                      \</span><br><span class="line">    --with-sysroot=<span class="variable">$LFS</span>                            \</span><br><span class="line">    --with-newlib                                  \</span><br><span class="line">    --without-headers                              \</span><br><span class="line">    --with-local-prefix=/tools                     \</span><br><span class="line">    --with-native-system-header-dir=/tools/include \</span><br><span class="line">    --disable-nls                                  \</span><br><span class="line">    --disable-shared                               \</span><br><span class="line">    --disable-multilib                             \</span><br><span class="line">    --disable-decimal-float                        \</span><br><span class="line">    --disable-threads                              \</span><br><span class="line">    --disable-libatomic                            \</span><br><span class="line">    --disable-libgomp                              \</span><br><span class="line">    --disable-libquadmath                          \</span><br><span class="line">    --disable-libssp                               \</span><br><span class="line">    --disable-libvtv                               \</span><br><span class="line">    --disable-libstdcxx                            \</span><br><span class="line">    --enable-languages=c,c++</span><br><span class="line"></span><br><span class="line"><span class="comment"># 编译非常耗时，生成的文件 3.1 GB</span></span><br><span class="line"><span class="comment"># 虚拟机是 2CPU，如果配置更高，可以使用更多CPU编译</span></span><br><span class="line">  make -j2</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="编译失败"><a href="#编译失败" class="headerlink" title="编译失败"></a>编译失败</h2><h3 id="gcc-第一次失败"><a href="#gcc-第一次失败" class="headerlink" title="gcc 第一次失败"></a>gcc 第一次失败</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">checking for x86_64-lfs-linux-gnu-gcc... &#x2F;mnt&#x2F;lfs&#x2F;sources&#x2F;build&#x2F;gcc&#x2F;build&#x2F;.&#x2F;gcc&#x2F;xgcc -B&#x2F;mnt&#x2F;lfs&#x2F;sources&#x2F;build&#x2F;gcc&#x2F;build&#x2F;.&#x2F;gcc&#x2F; -B&#x2F;tools&#x2F;x86_64-lfs-linux-gnu&#x2F;bin&#x2F; -B&#x2F;tools&#x2F;x86_64-lfs-linux-gnu&#x2F;lib&#x2F; -isystem &#x2F;tools&#x2F;x86_64-lfs-linux-gnu&#x2F;include -isystem &#x2F;tools&#x2F;x86_64-lfs-linux-gnu&#x2F;sys-include   </span><br><span class="line">checking for suffix of object files... configure: error: in &#96;&#x2F;mnt&#x2F;lfs&#x2F;sources&#x2F;build&#x2F;gcc&#x2F;build&#x2F;x86_64-lfs-linux-gnu&#x2F;libgcc&#39;:</span><br><span class="line">configure: error: cannot compute suffix of object files: cannot compile</span><br><span class="line">See &#96;config.log&#39; for more details</span><br><span class="line">make[1]: *** [Makefile:12427: configure-target-libgcc] Error 1</span><br><span class="line">make[1]: Leaving directory &#39;&#x2F;mnt&#x2F;lfs&#x2F;sources&#x2F;build&#x2F;gcc&#x2F;build&#39;</span><br><span class="line">make: *** [Makefile:940: all] Error 2</span><br><span class="line"></span><br><span class="line">检查日志 config.log,发现报错</span><br><span class="line">xxxxxxxxxx&#x2F;gcc&#x2F;as: line 106: exec: --: invalid option</span><br></pre></td></tr></table></figure>
<p><a target="_blank" rel="noopener" href="https://www.linuxquestions.org/questions/linux-from-scratch-13/lfs-7-6-chp-5-51-gcc-configure-error-cannot-compute-suffix-of-object-files-4175535347/?__cf_chl_jschl_tk__=43fc2ab4551edf5b94ee02bd3e5ecb1fd4a02ab3-1620826077-0-AX15lodTVAlg2jT9m8MhGgIAumUgTZHvC19b9CF1Oi43mhzczR4kPmbRtiKehO9esGyINdjnix1NkdpMHScEFw5Y1WDsNS3CHZdnSl04sZz_Zy9yMWA3imBKpCGVVzH0NaKsbWU6pZmcU4oCmJaTDiKYcIKRsw-6kON5X3cPPCfx-XgxCJpq5kUyy_gFwGyjSjLTa2Z8aa5lhhh0HSZ_OvISsWDfHcgLhJqiOJN19xoDECaRMc22DzB3yyZB9ZQLgNk6mp_FDFvQ4XV5YntrT6UlSQPa5ie7vmcag8GYD_h3CZteMER8M6KjWoRgwoiOfpu7TK_VVLo-oiaAhkQogopoA79f-dacERr7xmAoNHxr0KS6mb8c5DKydVaZM9uNY-h_zcSg4D_iDW5k0DAaOORFu73hNMALAQef4OpjKJhPGj18fuHI8r4rnLN3XPA9OLVf_0zxK7QOVA_TYDsetcONQ-hSmDkWa9lCEmvCAV80CTm67OxCNiqf6emRNPoFj4vxf7MJ8nfYD8jkdmxzKSjjhkIsZD9ugIGFjZdzg826OF878pqmBHjyW-A7OKesEU1JzWqQZwG9XKulMVDv25-xgdtTl285eIfRyjVnpYMU">社区问题解答1</a></p>
<p><a target="_blank" rel="noopener" href="https://blfs-support.linuxfromscratch.narkive.com/7PgxXohx/gcc-5-3-0-pass-1-build-error-solved">社区问题解答2</a></p>
<p>环境已经被污染了，重头再来一遍</p>
<h2 id="清理环境"><a href="#清理环境" class="headerlink" title="清理环境"></a>清理环境</h2><p>rm -rf /tools/*<br>rm -rf $LFS/sources/build/*</p>
<p>重新开始上面的<code>Binutils</code>和<code>GCC</code>编译 </p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/LFS/" rel="tag"># LFS</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/05/10/lfs-notebook-01/" rel="prev" title="lfs-notebook-01">
      <i class="fa fa-chevron-left"></i> lfs-notebook-01
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/05/13/lfs-notebook-03/" rel="next" title="lfs-notebook-03">
      lfs-notebook-03 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#LFS%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%EF%BC%88%E4%BA%8C%EF%BC%89"><span class="nav-number">1.</span> <span class="nav-text">LFS学习笔记（二）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BC%96%E8%AF%91-Binutils-2-32-%E7%AC%AC-1-%E9%81%8D"><span class="nav-number">1.1.</span> <span class="nav-text">编译 Binutils-2.32 - 第 1 遍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89GCC-9-2-0-%E7%AC%AC-1-%E9%81%8D"><span class="nav-number">1.2.</span> <span class="nav-text">安GCC-9.2.0 - 第 1 遍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BC%96%E8%AF%91%E5%A4%B1%E8%B4%A5"><span class="nav-number">1.3.</span> <span class="nav-text">编译失败</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#gcc-%E7%AC%AC%E4%B8%80%E6%AC%A1%E5%A4%B1%E8%B4%A5"><span class="nav-number">1.3.1.</span> <span class="nav-text">gcc 第一次失败</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%B8%85%E7%90%86%E7%8E%AF%E5%A2%83"><span class="nav-number">1.4.</span> <span class="nav-text">清理环境</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Movie</p>
  <div class="site-description" itemprop="description">学习，记录，分享，收获</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">14</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Movie</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>











<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js', () => {
    mermaid.initialize({
      theme    : 'forest',
      logLevel : 3,
      flowchart: { curve     : 'linear' },
      gantt    : { axisFormat: '%m/%d/%Y' },
      sequence : { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>


  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'bx3R5BB7VYCe0Yu5f4PF2Ako-gzGzoHsz',
      appKey     : '24eOkgM1v8hYTlnAO3C2eG3n',
      placeholder: "欢迎留言评论",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
